﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

public partial class cms_cmsServices : System.Web.UI.Page
{
    private const string ImageTopPin = "top_pin.jpg";
    private const string ImageActicle2 = "article2.jpg";
    private const string ImageActicle = "article.jpg";
    //private const string ImageIcon = "icon.jpg";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadImageDesign();
        }
    }

    private void LoadImageDesign()
    {
        if (File.Exists(Server.MapPath("~/images/" + ImageTopPin)))
        {
            imgTopPin.ImageUrl = "~/images/" + ImageTopPin;
            System.Drawing.Image img = System.Drawing.Image.FromFile(Server.MapPath("~/images/" + ImageTopPin));
            lblSize.Text = "(H x W:" + img.Height + " x " + img.Width + " )";
        }
        if (File.Exists(Server.MapPath("~/images/" + ImageActicle2)))
        {
            imgActicle2.ImageUrl = "~/images/" + ImageActicle2;
            System.Drawing.Image img = System.Drawing.Image.FromFile(Server.MapPath("~/images/" + ImageActicle2));
            lblSizeActicle2.Text = "(H x W:" + img.Height + " x " + img.Width + " )";
        }
        if (File.Exists(Server.MapPath("~/images/" + ImageActicle)))
        {
            imgActicle.ImageUrl = "~/images/" + ImageActicle;
            System.Drawing.Image img = System.Drawing.Image.FromFile(Server.MapPath("~/images/" + ImageActicle));
            lblSizeActicle.Text = "(H x W:" + img.Height + " x " + img.Width + " )";
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (FileUploadTopPin.HasFile && Utils.IsImageFile(FileUploadTopPin.FileName))
        {
            FileUploadTopPin.SaveAs(Server.MapPath("~/images/" + ImageTopPin));
        }
        if (FileUploadActicle2.HasFile && Utils.IsImageFile(FileUploadActicle2.FileName))
        {
            FileUploadActicle2.SaveAs(Server.MapPath("~/images/" + ImageActicle2));
        }
        if (FileUploadActicle.HasFile && Utils.IsImageFile(FileUploadActicle.FileName))
        {
            FileUploadActicle.SaveAs(Server.MapPath("~/images/" + ImageActicle));
        }
    }
}